import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.Persistence;


public class TestLifecycle {

	
	public static void main(String[] args) {

		EntityManagerFactory emf = Persistence
				.createEntityManagerFactory("myPersistenceUnit");
		EntityManager em = emf.createEntityManager();
		em.getTransaction().begin();
		Product p1=new Product ("boots",39310,"XTZ3JS","test");
		System.out.println(em.contains(p1));
		em.persist(p1);
		em.close();
		em.remove(p1);
		//em.persist(p1);
		//em.remove(p1);
		//em.refresh(p1);
	    //em.refresh(p1);
		//System.out.println(em.contains(p1));
		em.getTransaction().commit();
		em.close();
		emf.close();
	}
}
